const HttpClient = require('..').HttpClient;
const path = require("path");

tryHttpclient(HttpClient, 'urllib');

function tryHttpclient(HttpClient, name) {
  const options = {
    method: 'POST',
    timeout: 60000,
    timing: true,
    files:{
        media:path.join(path.dirname(__filename),'1.jpg')
    },
    dataType:'json'
  };
  console.log(options);
  const urllib = new HttpClient();
  const accessToken = `86_QCzhKDVSqJG_HOt0_TnIS7QeCYY4fyagQ_PzhMucvWzNJujWJXOXEqGCIq5KVxVHYuLkAzj83XgaIWWypU3q7WkOcFDEA9OvDpZJoUYn_Kxdll_5IqqLXrpz-UMGQVcABAVFK`;
  const imagetype = 'image';
  const url = `https://api.weixin.qq.com/cgi-bin/media/upload?access_token=${accessToken}&type=${imagetype}`;
//   urllib.on('response', function(info) {
//     // console.log(name, httpAgent, httpAgent.getCurrentStatus());
//     // console.log(name, httpsAgent, httpsAgent.getCurrentStatus());
//     console.log('response', name, info.res);
//   });
  urllib.request(url, options)
    .then(function(res) {
        console.log(res);
    //   return urllib.request('http://www.sizhijie.com', options);
    })
    .catch(function(err) {
      console.error('catch', err);
    });
}
